function sum(a) {
	if (arguments.length === 2) {
		return arguments[0] + arguments[1]
	} else {
		return function (b) {
			return a + b
		}
	}
}

console.log(sum(2, 3))
console.log(sum(2)(3))

function sum1(x, y) {
	if (y !== undefined) {
		return x + y
	} else {
		return function (y) {
			return x + y
		}
	}
}